<?
Class GenHtml {
	private $data;
	function __construct() {
	}

	function setData($data) {

		$this -> data = $data;
	}

	public function getTextPassword($label, $key, $custom = false) {

		
		if ($custom != false) {
			
			$value = "";
		} else {
			if (!empty($this -> data)) {
				$value = $this -> data -> $key;
			} else {
				$value = "";
			}
		}

		return '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
      <input value="' . $value . '" type="password" name="' . $key . '"" class="form-control" id="' . $key . '" placeholder="' . $label . '">
    </div>
  </div>';
	}

	public function getTextBox($label, $key) {

		if (!empty($this -> data)) {
			$value = $this -> data -> $key;
		} else {
			$value = "";
		}
		return '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
      <input value="' . $value . '" type="text" name="' . $key . '"" class="form-control" id="' . $key . '" placeholder="' . $label . '">
    </div>
  </div>';
	}

	public function getText($label, $key, $customValue = '') {

		if ($customValue == "") {
			$value = $this -> data -> $key;
		} else {
			$value = $customValue;
		}

		return '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
     <span style="line-height:20px">' . $value . '</span>
    </div>
  </div>';
	}

	public function getTextBoxDisable($label, $key) {

		$value = $this -> data -> $key;
		return '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
      <input readonly name="' . $key . '"" value="' . $value . '" type="text" class="form-control" id="' . $key . '" placeholder="' . $label . '">
    </div>
  </div>';
	}

	public function getButton($type, $id, $name, $class = 'default') {
		return '<div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="' . $type . '" id="' . $id . '" class="btn btn-' . $class . ' ' . $id . '">' . $name . '</button>
    </div>
  </div>';
	}

	public function getTextareaDefault($label, $key, $empty = false) {

		if ($empty == false) {
			$value = (isset($this -> data -> $key)) ? $this -> data -> $key : "";
		} else {
			$value = "";
		}
		$html = '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
      <textarea rows="10" class="form-control" id="' . $key . '" name="' . $key . '">' . $value . '</textarea>
    </div>
  </div>';
		return $html;
	}

	public function getComboBox($label, $name, $data, $key, $value) {
		$html = '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10"><select id="' . $name . '" name="' . $name . '" >';

		if (!empty($this -> data) && isset($this -> data -> $name)) {
			$values = $this -> data -> $name;
		} else {
			$values = "-1";
		}
		
		foreach ($data as $in => $val) {
			$val = (array)$val;
			$select = ($val[$key] == $values) ? 'selected="selected"' : "";
			$html .= '<option ' . $select . ' value="' . $val[$key] . '">' . $val[$value] . '</option>';
		}
		$html .= '</select></div></div>';
		return $html;
	}

	public function getTextArea($label, $key, $empty = false) {

		if ($empty == false) {
			$value = (isset($this -> data -> $key)) ? $this -> data -> $key : "";
		} else {
			$value = "";
		}
		$html = "";
		$html .= '<script src="//tinymce.cachefly.net/4.1/tinymce.min.js"></script>';
		$html .= '<script type="text/javascript">
tinymce.init({
    selector: "textarea",
    content_css : "' . base_url() . 'asset/css/core.css",
    theme: "modern",
    plugins: [
        "advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern"
    ],
    toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
    toolbar2: "print preview media | forecolor backcolor emoticons",
    image_advtab: true,
    templates: [
        {title: "Test template 1", content: "Test 1"},
        {title: "Test template 2", content: "Test 2"}
	
    ]
});
</script>';
		$html .= '<div class="form-group">
    <label for="' . $key . '" class="col-sm-2 control-label">' . $label . '</label>
    <div class="col-sm-10">
      <textarea rows="10" class="form-control" id="' . $key . '" name="' . $key . '">' . $value . '</textarea>
    </div>
  </div>';
		return $html;
	}

	public function getHidden($name, $key) {
		$value = $this -> data -> $key;
		return '<input type="hidden" name="' . $name . '"  class="' . $name . '"  id="' . $name . '" value="' . $value . '"/>';
	}

	public function getCheckBox($label, $key, $valueDefault) {
		$value = $this -> data -> $key;
		$checked = ($value == $valueDefault) ? 'checked="checked"' : "";
		$html = "";
		$html = '<div class="form-group">
		<div class="col-sm-2"><label>' . $label . '</label></div>
    <div class="col-sm-10">
      <div class="checkbox">
        
          <input ' . $checked . ' type="checkbox" class="checkbox" name="' . $key . '" value="' . $valueDefault . '"> 
        
      </div>
    </div>
  </div>';
		return $html;

	}
	public function getUpload(){
		$html = "";
		$html.='<span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>Select files...</span>
        <!-- The file input field used as target for the file upload widget -->
        <input id="fileupload" type="file" name="files[]" multiple>
    </span>
    <br>
    <br>
    <!-- The global progress bar -->
    <div id="progress" class="progress">
        <div class="progress-bar progress-bar-success"></div>
    </div>
    <!-- The container for the uploaded files -->
    <div id="files" class="files"></div>
    <br>';
	return $html;
	}
	

}
?>